package Runde3;

public class Triangle implements Polygon {

	private double a;
	private double b;
	private double c;
	
	//Create's a new Triangle with given side-lengths; a>0, b>0, c>0; a + b <= c 
	public Triangle(double a, double b, double c){
		this.a = a;
		this.b = b;
		this.c = c;
	}
	
	//Returns the triangle's area
	public double area() {
		//Heron's formula
		double s = perimeter()/2;
		return Math.sqrt(s*(s-a)*(s-b)*(s-c));
	}

	//Returns the triangle's perimieter
	public double perimeter() {
		return a+b+c;
	}
	
	//Sets the length of the triangle's a-side; newA > 0;  a + b <= c 
	public void setA(double newA) {
		a = newA;
	}
	
	//Sets the length of the triangle's b-side; newB > 0;  a + b <= c 
	public void setB(double newB) {
		b = newB;
	}
	
	//Sets the length of the triangle's c-side; newC > 0;  a + b <= c 
	public void setC(double newC) {
		c = newC;
	}

	//Returns the triangle's amount of edges (3)
	public int edges() {
		return 3;
	}

}
